package com.ict.web.controller.yzq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ict.web.dto.MilestoneInformationAddDto;
import com.ict.web.dto.MilestoneInformationEditDto;
import com.ict.web.vo.MilestoneInformationFinishTimeVo;
import com.ict.web.vo.MilestoneInformationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.web.domain.MilestoneInformation;
import com.ict.web.service.IMilestoneInformationService;
import com.ict.common.utils.poi.ExcelUtil;
import com.ict.common.core.page.TableDataInfo;

/**
 * 里程碑信息--刘杰Controller
 *
 * @author ruoyi
 * @date 2022-03-01
 */
@Api(tags = "里程碑信息")
@RestController
@RequestMapping("/milestone/information")
public class MilestoneInformationController extends BaseController
{
    @Autowired
    private IMilestoneInformationService milestoneInformationService;

    /**
     * 查询里程碑信息--刘杰列表
     */
    @GetMapping("/list/{proId}")
    @ApiOperation("查询里程碑信息")
    public TableDataInfo list(@PathVariable Long proId)
    {
        startPage();
        List<MilestoneInformationVo> list = milestoneInformationService.selectMilestoneInformationByProId(proId);
        return getDataTable(list);
    }

    /**
     * 导出里程碑信息--刘杰列表
     */
//    @PreAuthorize("@ss.hasPermi('web:information:export')")
    @Log(title = "里程碑信息--刘杰", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出里程碑信息")
    public void export(HttpServletResponse response, MilestoneInformation milestoneInformation)
    {
        List<MilestoneInformation> list = milestoneInformationService.selectMilestoneInformationList(milestoneInformation);
        ExcelUtil<MilestoneInformation> util = new ExcelUtil<MilestoneInformation>(MilestoneInformation.class);
        util.exportExcel(response, list, "里程碑信息--刘杰数据");
    }

    /**
     * 获取里程碑信息--刘杰详细信息
     */
//    @PreAuthorize("@ss.hasPermi('web:information:query')")
    @GetMapping(value = "/{milepostId}")
    @ApiOperation("获取里程碑信息")
    public MilestoneInformation getInfo(@PathVariable("milepostId") Long milepostId)
    {
        return milestoneInformationService.selectMilestoneInformationByMilepostId(milepostId);
    }

    /**
     * 新增里程碑信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:add')")
    @ApiOperation("新增里程碑信息")
    @Log(title = "里程碑信息--刘杰", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MilestoneInformationAddDto dto)
    {
        return toAjax(milestoneInformationService.insertMilestoneInformation(dto));
    }

    /**
     * 修改里程碑信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:edit')")
    @ApiOperation("修改里程碑信息")
    @Log(title = "里程碑信息--刘杰", businessType = BusinessType.UPDATE)
    @PutMapping("/edit/{milepostId}")
    public AjaxResult edit(@RequestBody MilestoneInformationAddDto dto)
    {
        return toAjax(milestoneInformationService.updateMilestoneInformation(dto));
    }

    /**
     * 删除里程碑信息--刘杰
     */
//    @PreAuthorize("@ss.hasPermi('web:information:remove')")
    @ApiOperation("删除里程碑信息")
    @Log(title = "里程碑信息--刘杰", businessType = BusinessType.DELETE)
	@DeleteMapping("/{milepostId}")
    public AjaxResult remove(@PathVariable Long milepostId)
    {
        return toAjax(milestoneInformationService.deleteMilestoneInformationByMilepostId(milepostId));
    }

    @ApiOperation("完成时间")
    @GetMapping("/finishTime/{projectId}")
    public MilestoneInformationFinishTimeVo finishTime(@PathVariable Long projectId){
        return milestoneInformationService.finishTime(projectId);
    }
}
